package com.xdb.sqlparser.ast.statement;

import com.xdb.sqlparser.ast.AbstractSQLStatementImpl;
import com.xdb.sqlparser.visitor.SQLAstVisitor;
/**
 * 表示查询语句
 * @author woate
 *
 */
public class SQLSelectStatement extends AbstractSQLStatementImpl {
	/**
	 * 查询语句块
	 */
	protected SQLSelect select;

	public SQLSelectStatement() {

	}

	public SQLSelectStatement(String dbType) {
		super(dbType);
	}

	public SQLSelectStatement(SQLSelect select) {
		this.setSelect(select);
	}

	public SQLSelectStatement(SQLSelect select, String dbType) {
		this(dbType);
		this.setSelect(select);
	}
	/**
	 * 获取查询语句块
	 * @return
	 */
	public SQLSelect getSelect() {
		return this.select;
	}
	/**
	 * 设置查询语句块
	 * @param select
	 */
	public void setSelect(SQLSelect select) {
		if (select != null) {
			select.setParent(this);
		}
		this.select = select;
	}

	public void output(StringBuffer buf) {
		this.select.output(buf);
	}
	
	protected void accept0(SQLAstVisitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, this.select);
		}
		visitor.endVisit(this);
	}
}
